Skip to content

cli/compose/loader: remove some wrapper utilities and use errors.Join#6809

Open
thaJeztah wants to merge 2 commits intodocker:masterfrom
thaJeztah:compose_rm_utils
Open

cli/compose/loader: remove some wrapper utilities and use errors.Join#6809
thaJeztah wants to merge 2 commits intodocker:masterfrom
thaJeztah:compose_rm_utils

Conversation

@thaJeztah
Copy link
Member

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah added status/2-code-review area/stack kind/refactor PR's that refactor, or clean-up code labels Feb 19, 2026
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 12.50000% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cli/compose/loader/merge.go 12.50% 7 Missing and 7 partials ⚠️

📢 Thoughts on this report? Let us know!

@thaJeztah thaJeztah marked this pull request as ready for review February 27, 2026 14:25
@thaJeztah thaJeztah added this to the 29.3.0 milestone Feb 27, 2026
@thaJeztah thaJeztah requested a review from Copilot February 27, 2026 17:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the Compose config merge logic in cli/compose/loader to remove small wrapper utilities and use errors.Join for aggregating merge errors while merging multiple compose files.

Changes:

  • Aggregate per-file merge errors using errors.Join instead of returning on the first merge failure.
  • Inline map-merging wrappers (volumes/networks/secrets/configs) by calling mergo.Map directly.
  • Fix mergeServices to return nil (not the base slice) on error.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

errs = append(errs, fmt.Errorf("cannot merge configs: %w", err))
}
if err := errors.Join(errs...); err != nil {
return nil, errors.Join(fmt.Errorf("failed to merge file %s", override.Filename), err)
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The top-level error is built with errors.Join, which makes the file-context a separate error line and loses normal wrapping semantics. Consider wrapping the joined merge errors instead (e.g., include the filename in a single fmt.Errorf with %w), and use %q for the filename for clearer output.

Suggested change
return nil, errors.Join(fmt.Errorf("failed to merge file %s", override.Filename), err)
return nil, fmt.Errorf("failed to merge file %q: %w", override.Filename, err)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/stack kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants